package com.ruoyi.classai.service.impl;


import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.github.yulichang.base.MPJBaseServiceImpl;
import com.ruoyi.classai.domain.EwcCourseGrouping;
import com.ruoyi.classai.domain.dto.StudentLoginDto;
import com.ruoyi.classai.domain.vo.StudentGroupVo;
import com.ruoyi.classai.mapper.EwcCourseGroupingMapper;
import com.ruoyi.classai.mapper.EwcStudentGroupMapper;
import com.ruoyi.classai.service.IEwcStudentGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


/**
 * 学生信息Service业务层处理
 * 
 * @author zsp
 * @date 2025-03-18
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class EwcStudentGroupServiceImpl extends MPJBaseServiceImpl<EwcCourseGroupingMapper, EwcCourseGrouping> implements IEwcStudentGroupService {

    @Autowired
    private EwcStudentGroupMapper ewcStudentGroupMapper;

    @Override
    public StudentGroupVo getStudentGroupInfo(StudentLoginDto studentLoginDto) {
        return ewcStudentGroupMapper.getStudentGroupInfo(studentLoginDto);
    }

    @Override
    public boolean updateBySIDAndGID(EwcCourseGrouping ewcCourseGrouping) {
        // 创建 UpdateWrapper 对象
        UpdateWrapper<EwcCourseGrouping> updateWrapper = new UpdateWrapper<>();
        // 设置更新条件
        updateWrapper.eq("grouping_id", ewcCourseGrouping.getGroupingId())
                .eq("student_id", ewcCourseGrouping.getStudentId());
        EwcCourseGrouping entity = new EwcCourseGrouping();
        entity.setUpdateTime(ewcCourseGrouping.getUpdateTime());
        entity.setVideoPath(ewcCourseGrouping.getVideoPath());
        entity.setTaskId(ewcCourseGrouping.getTaskId());
        return this.update(entity,updateWrapper);
    }
}
